//! @Author: DengLibin 榆霖
//! @Date:  2022-07-07 16:20:30
//! @Description: 文章 service


use dao::{pojo::{PageInfo, DbParam, ArticleParam}, entity::article::Article, article_dao};


/// @Author: DengLibin 榆霖
/// @Date:  2022-07-05 13:45:01
/// @Description: 分页查询
pub fn get_page(param: &DbParam) ->  Result<PageInfo<Article>, Box<dyn std::error::Error>> {

    article_dao::get_page(param.page, param.size, &param.pool)
}

/// @Author: DengLibin 榆霖
/// @Date:  2022-07-05 13:45:01
/// @Description: 插入
pub fn insert(param: &ArticleParam) ->  Result<bool, Box<dyn std::error::Error>> {

    article_dao::insert(&param.article, &param.pool)
}

/// @Author: DengLibin 榆霖
/// @Date:  2022-07-18 16:19:58
/// @Description: 根据id查询
pub fn get_by_id(id: i64, pool: &mysql::Pool) -> Option<Article> {
    article_dao::get_by_id(id, pool)
}

/// @Author: DengLibin 榆霖
/// @Date:  2022-07-18 16:27:22
/// @Description: 查询所有
pub fn get_all(pool: &mysql::Pool) -> Result<Vec<Article>, Box<dyn std::error::Error>> {
    article_dao::get_all(pool)
}